package org.ccay.core.request;

import org.ccay.core.exception.ApplicationException;

/**
 * RequestContext 持有器，用于后台任务执行
 * @author chaowangbang
 * @since 2012-6-27
 */
public interface IRequestContextHolder {

    /** 
    * 开始持有RequestContext 
    * @param userAccount 模拟的用户
    * @param ignoreSecurityCheck 忽略后继权限检查
     * @throws ApplicationException 模拟的用户在用户表中不存在时抛出异常
     */
    void begin(String userAccount, boolean skipSecurityCheck)  throws ApplicationException;
    
    /** 
     * 开始持有RequestContext 
     * @author chaowangbang
     * @since 2012-9-16
    * @param userAccount 模拟的用户
    * @param ignoreSecurityCheck 忽略后继权限检查
     * @param autoCreateUser 自动创建虚拟用户
     * @throws ApplicationException  程序发生异常
     */
    void begin(String userAccount, boolean skipSecurityCheck, boolean autoCreateUser)  throws ApplicationException;
    
    /** 
     * 结束持有
     */
    void end();

	/** 
	 * 构建上下文
	 * @author chaowangbang
	 * @since 2012-10-31
	 * @param userName
	 * @param skipSecurityCheck
	 * @param autoCreateUser
	 * @return
	 * @throws ApplicationException
	 */
	IRequestContext buildVirutalContext(String userName, boolean skipSecurityCheck, boolean autoCreateUser) throws ApplicationException;
    
}
